## Figure A3: Clustering of Closing Dates by Day of Month and City

## install.packages(c("tidyverse"))
## library(tidyverse)

## SET WORKING DIRECTORY HERE
## setwd()

## Loading data
## load("dta.RData")

clustering_days_of_month = dta %>%
  filter(!is.na(close_day_of_month)) %>%
  mutate(n = 1,
         close_day_of_month = factor(close_day_of_month)) %>%
  group_by(city, close_day_of_month) %>%
  summarise(n_requests_closed = sum(n, na.rm = TRUE)) %>%
  ggplot(aes(x = factor(close_day_of_month), y = n_requests_closed)) +
  facet_wrap(city ~ ., scales = "free", ncol = 2) +
  geom_bar(stat = "identity", color="black", fill="gray") +
  scale_x_discrete(labels = c("1", "", "", "", "", "", "", "",
                              "", "", "", "", "", "", "15", "",
                              "", "", "", "", "", "", "", "",
                              "", "", "", "", "", "30", "")) +
  labs(x = "Day of Month",
       y = "# of Requests Closed") +
  theme_classic() +
  theme(panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_rect(colour = "black"))